package com.workcell.workdata.im.component.event;

import com.farsunset.cim.model.Message;
import com.workcell.workdata.im.constant.MessageActionGroup;
import org.springframework.context.ApplicationEvent;

import java.util.List;
import java.util.stream.Collectors;


public class ThirdMessagePushEvent extends ApplicationEvent {

    private final List<Message> messageList;

    private final String traceId;

    public ThirdMessagePushEvent(List<Message> messageList, String traceId) {
        super("");
        this.messageList = messageList
                .stream()
                .filter(message -> MessageActionGroup.PUSHABLE.contains(message.getAction()))
                .collect(Collectors.toList());
        this.traceId = traceId;
    }

    public List<Message> getMessageList() {
        return messageList;
    }

    public boolean isNotEmpty(){
        return !messageList.isEmpty();
    }

    public String getTraceId() {
        return traceId;
    }
}
